package yawning.mew.cat;

import yawning.mew.BuffsDebuffs.Buff;
import yawning.mew.sim.SimulationEvent;

public class EventToTT extends SimulationEvent {
	CatModelSimState mState;
	private double mCooldownExpireTime;
	private double mMult = 1.0;

	EventToTT(CatModelSimState state) {
		super(state.mSimEngine);
		if (state.mModel.buffsDebuffs.isBuff(Buff.TRICKSOFTHETRADE)) schedule(0.0);
		mState = state;
	}

	@Override
	public void onExpire() {
		if (mCooldownExpireTime > mState.mSimEngine.getSimTime()) {
			if (mState.mIsLogging) mState.mLog.log("Tricks of the Trade: Expiration\n");
			mMult = 1.0;
			schedule(mCooldownExpireTime - mState.mSimEngine.getSimTime());
		} else {
			if (mState.mIsLogging) mState.mLog.log("Tricks of the Trade\n");
			mMult = mState.mModel.buffToTT;
			schedule(mState.mModel.tottBuffDuration);
			mCooldownExpireTime = mState.mSimEngine.getSimTime() + mState.mModel.tottCDDuration;
		}
	}

	public double getMult() {
		return mMult;
	}
}